﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Numbers;
using Microsoft.Silverlight.Testing;

namespace t_Numbers
{
    [TestClass]
    public class t_epsilon_12
    {
        [TestMethod]
        public void TestCreator()
        {
            FlavorSample num = new FlavorSample();
            FlavorSample denom = new FlavorSample();

            var e = new epsilon_12(num, denom);

            Assert.AreEqual(0.0, e.Value, "Divide by zero should not cause problems!");
        }

        [TestMethod]
        public void TestResults()
        {
            FlavorSample num = new FlavorSample();
            FlavorSample denom = new FlavorSample();

            var e = new epsilon_12(num, denom);

            num.Charm = 100;
            denom.Charm = 200;

            Assert.AreEqual(0.5, e.Value, "Charm setting only doesn'tn seem to work");

            num.Light = 100;
            denom.Light = 800;
            Assert.AreEqual(0.2, e.Value, "The light doesn't seem to be wired up right");
        }

        [TestMethod]
        public void TestChangedEvent()
        {
            FlavorSample num = new FlavorSample();
            FlavorSample denom = new FlavorSample();

            var e = new epsilon_12(num, denom);

            int count = 0;
            e.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((o, args) => { count += 1; });

            num.Charm = 100;
            Assert.AreEqual(0, count, "Prop should not fire when no change actually happens to the value");

            denom.Charm = 100.0;
            Assert.AreEqual(1, count, "Prop should have fired!");
        }

        [TestMethod]
        public void TestInitialValue()
        {
            FlavorSample num = new FlavorSample();
            FlavorSample denom = new FlavorSample();

            num.Charm = 100;
            denom.Charm = 200;

            var e = new epsilon_12(num, denom);

            Assert.AreEqual(0.5, e.Value, "Initial calculation doesn't seem to have been preformed!");
        }

        [TestMethod]
        public void TestDivideByZero()
        {
            FlavorSample num = new FlavorSample();
            FlavorSample denom = new FlavorSample();

            var e = new epsilon_12(num, denom);

            Assert.AreEqual(0.0, e.Value, "Divide by zero isn't dealt with correctly!");
        }
    }
}